import { useAsync } from './use-async'
import { clearEmptyKey } from 'utils'
import { useEffect } from 'react'
import { useHttp } from 'utils/http'
import { IUser } from 'screens/project-list/search-panel'
export const useUsers = (param?: Partial<IUser>) => {
  const { run, ...result } = useAsync<IUser[]>()
  const client = useHttp()

  // 当param发生变化时,请求数据
  useEffect(() => {
    run(client('users', { data: clearEmptyKey(param || {}) }))
  }, [param])

  return result
}
